package com.bltec.emergency.mapper;

import com.bltec.emergency.model.ResponseStatistics;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;
@Mapper
public interface ResponseStatisticsMapper {
    //插入一条ResponseStatistics记录
    @Insert("insert into response_statistics (material_category,department_id,time,type," +
            "create_by,create_time,enable) " +
            "values(#{materialCategory},#{departmentId},#{time},#{type}," +
            "#{createBy},#{createTime},#{enable})")
    boolean insert(ResponseStatistics responseStatistics);

    //通过id设置一条记录为不可用
    @Update("update response_statistics set enable=0 where id=#{id}")
    boolean setDisableById(Long id);

    //通过id更新一条记录
    @Update("update response_statistics set material_category=#{materialCategory},department_id=#{departmentId},time=#{time},type=#{type}," +
            "update_by=#{updateBy},update_time=#{updateTime} where id=#{id}")
    boolean updateResponseStatisticsById(ResponseStatistics responseStatistics);

    //查找符合id字段的记录
    @Select("select id,material_category,department_id,time,type," +
            "create_by,create_time,update_by,update_time,enable" +
            " from response_statistics where id =#{id} and enable=1")
    ResponseStatistics getResponseStatisticsById(Long id);

    //查找所有记录
    @Select("select id,material_category,department_id,time,type," +
            "create_by,create_time,update_by,update_time,enable" +
            " from response_statistics where enable=1")
    List<ResponseStatistics> selectAll();
}